package com.oscroll.prototype.lesson;

import java.util.ArrayList;

public class Test {

    public static void main(String[] args) {
//        simpleTest();
        deepTest1();
    }

    public static void simpleTest() {
        Simple s = new Simple();
        s.setName("lw");
        ArrayList<CloneTarget> arrayList = new ArrayList();
        arrayList.add(new CloneTarget());
        s.setList(arrayList);

        try {
            Simple obj = (Simple) s.clone();
//            System.out.println(obj.getName());
//            System.out.println(obj.getList());
//            System.out.println(s.getList());
            System.out.println(s == obj);
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }

    }

    public static void deepTest(){
        WuKong wuKong = new WuKong();

        try {
            WuKong clone = (WuKong)wuKong.clone();

            System.out.println(wuKong == clone);
            System.out.println(wuKong.getJinGuBang() == clone.getJinGuBang());
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
    }

    public static void deepTest1(){
        WuKong wuKong = new WuKong();

        try {
            WuKong clone = (WuKong)wuKong.deepClone();

            System.out.println(wuKong == clone);
            System.out.println(wuKong.getJinGuBang() == clone.getJinGuBang());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
